﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.IO;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.ComponentModel;
using System.Drawing.Drawing2D;
using HospitalSystem.Core;

namespace HospitalSystem
{
    public partial class reg : System.Web.UI.Page
    {
        private RegisterLog _RL;
        // SqlConnection conn = new SqlConnection(@"Data Source=SJ-PC\SQLEXPRESS;Initial Catalog=db0015;Integrated Security=True");
        string strConnString = ConfigurationManager.ConnectionStrings["strconnection"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["idlogin"] == null)
            {

                MessageBoxurl("กรุณาlogin ก่อน", "index.aspx");

            }
            else
            {




                showsession();
                _RL = new RegisterLog();
                String ShowValue = (string)Session["idlogin"];

                if (!IsPostBack)
                {
                    findstaffID();

                    _RL.loaddatadropdownDisabilityType(DisabilityType);

                }
            }



        }
        private void MessageBoxurl(string msg, string urld)
        {
            Label lbl = new Label();
            lbl.Text = "<script language='javascript'>" + Environment.NewLine + "window.alert('" + msg + "');" + "window.location.href='" + urld + "';" + "</script>";
            Page.Controls.Add(lbl);
        }
        protected void findstaffID()
        {



            string constr = WebConfigurationManager.ConnectionStrings["strconnection"].ConnectionString;
            SqlConnection conn = new SqlConnection(constr);

            SqlCommand CmdSql2 = new SqlCommand("SELECT Staff_id FROM [Employee] where Username=@Username", conn);
            conn.Open();
            CmdSql2.Parameters.AddWithValue("@Username", Session["idlogin"]);

            SqlDataReader reader2 = CmdSql2.ExecuteReader();



            if (reader2.Read())
            {
                RecordedStaffID.Text = reader2["Staff_id"].ToString();


            }
            else
            {

            }
            conn.Close();
            reader2.Close();
           
        }

        private void MessageBox(string msg)
        {
            Label lbl = new Label();
            lbl.Text = "<script language='javascript'>" + Environment.NewLine + "window.alert('" + msg + "')</script>";
            Page.Controls.Add(lbl);
        }
        protected void reg_Click1(object sender, EventArgs e)
        {
            _RL.insertregdata(CID.Text, LastName.Text, FirstName.Text, Gender, BloodType, birthday.Text, Nation.Text, Race.Text, Religion.Text, Foreigner.Text, LiveHomeStatus.Text, EducationStatus.Text, LiveStreetAddress.Text, LiveStreetName.Text, Livetumbon.Text, LiveCity.Text, LiveProvince.Text, LivePostcode.Text, CensusStreetAddress.Text, CensusStreetName.Text, Censustumbon.Text, CensusCity.Text, CensusProvince.Text, CensusPostcode.Text, HomePhone.Text, Mobile.Text, RecordedStaffID.Text, LiveMoveInDate2.Text, LiveMoveOutReason, CensusMoveOutReason, LiveMoveOutDate2.Text, CensusMoveInDate2.Text, CensusMoveOutDate2.Text, Titles, DisabilityType, CensusHouseMoo.Text, CensusHouseName.Text, CensusHousesoy.Text, LiveHouseMoo.Text, LiveHouseName.Text, LiveHousesoy.Text);//CensusHousesoy,LiveHouseMoo,LiveHouseName,LiveHousesoy
            sessionsend();
            ImageUpload_f();
            ImageUpload_cid();
            Response.Redirect("~/regok.aspx");
        }



        protected void showsession()
        {
            String ShowValue = (string)Session["CID"];
            cid_label.Text = ShowValue;
           


        }



        protected void sessionsend()
        {
            Session["LastName"] = LastName.Text;
            Session["FirstName"] = FirstName.Text;
            Session["CID"] = CID.Text;
            String CIDLabel = (string)Session["CID"];
            CIDlabel.Text = CIDLabel;
           
        }

        protected void Button3_Click(object sender, EventArgs e)
        {



        }

        protected void Button2_Click1(object sender, EventArgs e)
        {
           checkcid13();
        }








        protected void checkcid()
        {
            string constr = WebConfigurationManager.ConnectionStrings["strconnection"].ConnectionString;
            SqlConnection conn2 = new SqlConnection(constr);
            SqlCommand cmd22 = new SqlCommand("SELECT CID FROM [Person] where CID=@CID", conn2);


            conn2.Open();
            cmd22.Parameters.AddWithValue("@CID", CID.Text);

            SqlDataReader reader32 = cmd22.ExecuteReader();



            if (reader32.Read())
            {

                MessageBox("เลขบัตรประชาชนนี้มีการลงทะเบียนแล้วครับ  กรุณาไปหน้าค้นหาเด็กแล้ว");
                CIDST.Text = "Fail!!";
                reg_button.Visible = false;
                sessionsend();

            }
            else
            {
                
                MessageBox("เลขบัตรประชาชนนี้สามารถใช้ได้");
                CIDST.Text = "Pass!!";
                reg_button.Visible = true;
                sessionsend();
            }
            conn2.Close();
            reader32.Close();
        }



        


        protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
        {
            //สร้างที่อยู่อัตโนมัติกรณีใช้ตามทะเบียนบ้าน
            bindtextbox();
        }




        protected void bindtextbox()
        {
            Session["StreetAddress"] = CensusStreetAddress.Text;
            Session["StreetName"] = CensusStreetName.Text;
            Session["tumbon"] = Censustumbon.Text;
            Session["City"] = CensusCity.Text;
            Session["Province"] = CensusProvince.Text;
            Session["Postcode"] = CensusPostcode.Text;

            Session["inhome"] = CensusMoveInDate2.Text;
            Session["out"] = CensusMoveOutDate2.Text;

            Session["CensusHousesoy"] = CensusHousesoy.Text;
            Session["CensusHouseName"] = CensusHouseName.Text;
            Session["CensusHouseMoo"] = CensusHouseMoo.Text;




            String CensusHousesoys = (string)Session["CensusHousesoy"];
            LiveHousesoy.Text = CensusHousesoys;

            String CensusHouseNames = (string)Session["CensusHouseName"];
            LiveHouseName.Text = CensusHouseNames;
            String CensusHouseMoos = (string)Session["CensusHouseMoo"];
            LiveHouseMoo.Text = CensusHouseMoos;




            String StreetAddress = (string)Session["StreetAddress"];
            LiveStreetAddress.Text = StreetAddress;
            String StreetName = (string)Session["StreetName"];
            LiveStreetName.Text = StreetName;

            String Province = (string)Session["Province"];
            LiveProvince.Text = Province;

            String Postcode = (string)Session["Postcode"];
            LivePostcode.Text = Postcode;

            String City = (string)Session["City"];
            LiveCity.Text = City;

            String tumbon = (string)Session["tumbon"];
            Livetumbon.Text = tumbon;

            String inhome = (string)Session["inhome"];
            LiveMoveInDate2.Text = inhome;
            String outhome = (string)Session["out"];
            LiveMoveOutDate2.Text = outhome;

        }



        //private Boolean PIDChecker(String PID)
        //{
        //    if (PID.Trim().Length != 13)
        //        return false;
        //    int y = 0;
        //    for (int i = 0; i < PID.Length - 1; i++)
        //        y += int.Parse(PID[i].ToString()) * (13 - i);
        //    int x = 11 - (y % 11);
        //    return PID[12].ToString() == x.ToString();
        //}

        protected void CID_TextChanged(object sender, EventArgs e)
        {
            checkcid13();
        }


        protected void checkcid13()
        {
            if (_RL.ValidateNumber(CID.Text))
            {
                if (_RL.PIDChecker(CID.Text))
                {
                    CIDST.Text = "Pass!!";
                    checkcid();
                 
                }
                else
                {
                    CIDST.Text = "Fail!!";
                    MessageBox("เลขบัตรประชาชนไม่ถูกต้อง");
                    reg_button.Visible = false;
                    
                }
            }
            else
            {
                CIDST.Text = "Fail!!";
                MessageBox("กรุณาใส่ตัวเลข");
                reg_button.Visible = false;
            }
        }




        protected void ImageUpload_f()
        {
            SqlConnection conn = new SqlConnection(strConnString);
            if (FileUploader.HasFile)
            {
                //try
                //{



                conn.Open();
                SqlCommand cmd = new SqlCommand("delete from ImageDek where Iddek=@CID", conn);
                cmd.Parameters.AddWithValue("@CID", CIDlabel.Text);
                cmd.ExecuteNonQuery();

                conn.Close();





                //ไปใส่พาธไฟล์เอา

                string MapPath = ("~/pic/profile/");
                string filename = CIDlabel.Text;
                FileUploader.SaveAs(Server.MapPath(MapPath) + filename + Path.GetExtension(FileUploader.FileName));
                
                string Includepath = ((MapPath) + filename + Path.GetExtension(FileUploader.FileName));
                Bitmap originalBMP = new Bitmap(FileUploader.FileContent);
              
                int newWidth = 200;
                int newHeight = 200;
                Bitmap newBMP = new Bitmap(originalBMP, newWidth, newHeight);
                Graphics oGraphics = Graphics.FromImage(newBMP);
                oGraphics.SmoothingMode = SmoothingMode.AntiAlias; oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight);
                newBMP.Save(Server.MapPath(MapPath + filename + Path.GetExtension(FileUploader.FileName)));
                originalBMP.Dispose();
                newBMP.Dispose();
                oGraphics.Dispose();

                string constr = WebConfigurationManager.ConnectionStrings["strconnection"].ConnectionString;
                SqlConnection scon = new SqlConnection(constr);
                SqlCommand cmd22 = new SqlCommand("INSERT INTO [ImageDek] ([Iddek],[FilePath],dateupdate) VALUES (@Iddek,@Filepath,@dateupdate)", scon);
                cmd22.Parameters.AddWithValue("@Iddek", CIDlabel.Text);
                cmd22.Parameters.AddWithValue("@FilePath", Includepath);
                cmd22.Parameters.AddWithValue("@dateupdate", DateTime.Now);


                scon.Open();
                cmd22.ExecuteNonQuery();
                scon.Close();

             
                //xxx คิวรีมาจาก db เอา
                //Image1.ImageUrl = Server.MapPath("xxx");




                //}
                //catch
                //{

                //}
            }
        }




        protected void ImageUpload_cid()
        {
            SqlConnection conn = new SqlConnection(strConnString);
            if (FileUploadercid.HasFile)
            {
                //try
                //{



                conn.Open();
                SqlCommand cmd = new SqlCommand("delete from pic_cid where Iddek=@CID", conn);
                cmd.Parameters.AddWithValue("@CID", CIDlabel.Text);
                cmd.ExecuteNonQuery();

                conn.Close();





                //ไปใส่พาธไฟล์เอา

                string MapPath = ("~/pic/cid/");
                string filename = CIDlabel.Text;
                FileUploadercid.SaveAs(Server.MapPath(MapPath) + filename + Path.GetExtension(FileUploadercid.FileName));

                string Includepath = ((MapPath) + filename + Path.GetExtension(FileUploadercid.FileName));
                Bitmap originalBMP = new Bitmap(FileUploadercid.FileContent);

                int newWidth = 200;
                int newHeight = 200;
                Bitmap newBMP = new Bitmap(originalBMP, newWidth, newHeight);
                Graphics oGraphics = Graphics.FromImage(newBMP);
                oGraphics.SmoothingMode = SmoothingMode.AntiAlias; oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight);
                newBMP.Save(Server.MapPath(MapPath + filename + Path.GetExtension(FileUploadercid.FileName)));
                originalBMP.Dispose();
                newBMP.Dispose();
                oGraphics.Dispose();

                string constr = WebConfigurationManager.ConnectionStrings["strconnection"].ConnectionString;
                SqlConnection scon = new SqlConnection(constr);
                SqlCommand cmd22 = new SqlCommand("INSERT INTO [pic_cid] ([cid],[FilePath],dateupdate) VALUES (@Iddek,@Filepath,@dateupdate)", scon);
                cmd22.Parameters.AddWithValue("@Iddek", CIDlabel.Text);
                cmd22.Parameters.AddWithValue("@FilePath", Includepath);
                cmd22.Parameters.AddWithValue("@dateupdate", DateTime.Now);


                scon.Open();
                cmd22.ExecuteNonQuery();
                scon.Close();

            }
        }





        protected void Button3_Click1(object sender, EventArgs e)
        {

        }

        protected void ImageUpload_Click(object sender, EventArgs e)
        {
            ImageUpload_f();
        }

        protected void BDIB_Click(object sender, ImageClickEventArgs e)
        {
            BDCal.Visible = true;
        }

        protected void CMIDIB_Click(object sender, ImageClickEventArgs e)
        {
            CMIDCal.Visible = true;
        }

        protected void CMODIB_Click(object sender, ImageClickEventArgs e)
        {
            CMODCal.Visible = true;
        }

        protected void LMIDIB_Click(object sender, ImageClickEventArgs e)
        {
            LMIDCal.Visible = true;
        }

        protected void LMODIB_Click(object sender, ImageClickEventArgs e)
        {
            LMODCal.Visible = true;
        }

        protected void LMIDCal_SelectionChanged(object sender, EventArgs e)
        {
            LiveMoveInDate2.Text = LMIDCal.SelectedDate.ToShortDateString();
            LMIDCal.Visible = false;
        }

        protected void BDCal_SelectionChanged(object sender, EventArgs e)
        {
            birthday.Text = BDCal.SelectedDate.ToShortDateString();
            BDCal.Visible = false;
        }

        protected void CMIDCal_SelectionChanged(object sender, EventArgs e)
        {
            CensusMoveInDate2.Text = CMIDCal.SelectedDate.ToShortDateString();
            CMIDCal.Visible = false;
        }

        protected void CMODCal_SelectionChanged(object sender, EventArgs e)
        {
            CensusMoveOutDate2.Text = CMODCal.SelectedDate.ToShortDateString();
            CMODCal.Visible = false;
        }

        protected void LMODCal_SelectionChanged(object sender, EventArgs e)
        {
            LiveMoveOutDate2.Text = LMODCal.SelectedDate.ToShortDateString();
            LMODCal.Visible = false;
        }







        //   //ดึงข้อมูลมาโชว์หน้า reg.aspx



        //protected void loaddatareg()
        //{
                        

        //    string constr = WebConfigurationManager.ConnectionStrings["strconnection"].ConnectionString;
        //    SqlConnection conn = new SqlConnection(constr);


        //    SqlCommand CmdSql2 = new SqlCommand("SELECT Gender,BloodType,CID,Title,FirstName,LastName,DOB,Nation,Race,Religion,Foreigner,LiveHomeStatus,EducationStatus,LiveStreetAddress,LiveStreetName,Livetumbon,LiveCity,LiveProvince,LivePostcode,CensusStreetAddress,CensusStreetName,Censustumbon,CensusCity,CensusProvince,CensusPostcode,HomePhone,Mobile,RecordedStaffID,LiveMoveInDate,LiveMoveOutDate,CensusMoveInDate,CensusMoveOutDate,LiveMoveOutReason,CensusMoveOutReason FROM [Person] where CID=@CID", conn);
        //    conn.Open();
        //    CmdSql2.Parameters.AddWithValue("@CID", cid_label.Text);

        //    SqlDataReader reader2 = CmdSql2.ExecuteReader();

        //    //CmdSql.Parameters.AddWithValue("@Gender", RadioButtonList1.SelectedValue);
        //    // CmdSql.Parameters.AddWithValue("@BloodType", RadioButtonList2.SelectedValue);
        //    // CensusCity,CensusProvince,CensusPostcode,HomePhone,Mobile,RecordedStaffID
        //    if (reader2.Read())
        //    {
        //        Gender.SelectedValue = reader2["Gender"].ToString();
        //        BloodType.SelectedValue = reader2["BloodType"].ToString();
        //        FirstName.Text = reader2["FirstName"].ToString();
        //        LastName.Text = reader2["LastName"].ToString();
        //        CID.Text = reader2["CID"].ToString();
        //        birthday.Text = reader2["DOB"].ToString();
        //        Nation.Text = reader2["Nation"].ToString();
        //        Race.Text = reader2["Race"].ToString();
        //        Religion.Text = reader2["Religion"].ToString();
        //        Foreigner.Text = reader2["Foreigner"].ToString();
        //        LiveStreetAddress.Text = reader2["LiveStreetAddress"].ToString();
        //        LiveStreetName.Text = reader2["LiveStreetName"].ToString();
        //        Livetumbon.Text = reader2["Livetumbon"].ToString();
        //        LiveCity.Text = reader2["LiveCity"].ToString();
        //        LiveProvince.Text = reader2["LiveProvince"].ToString();
        //        LivePostcode.Text = reader2["LivePostcode"].ToString();
        //        CensusStreetAddress.Text = reader2["CensusStreetAddress"].ToString();
        //        CensusStreetName.Text = reader2["CensusStreetName"].ToString();
        //        Censustumbon.Text = reader2["Censustumbon"].ToString();
        //        CensusCity.Text = reader2["CensusCity"].ToString();
        //        CensusProvince.Text = reader2["CensusProvince"].ToString();
        //        CensusPostcode.Text = reader2["CensusPostcode"].ToString();
        //        HomePhone.Text = reader2["HomePhone"].ToString();
        //        Mobile.Text = reader2["Mobile"].ToString();
        //        RecordedStaffID.Text = reader2["RecordedStaffID"].ToString();
                
        //        //LiveMoveInDate,LiveMoveOutDate,CensusMoveInDate,CensusMoveOutDate  LiveMoveOutReason,CensusMoveOutReason
        //        LiveMoveOutReason.SelectedValue = reader2["LiveMoveOutReason"].ToString();
        //        CensusMoveOutReason.SelectedValue = reader2["CensusMoveOutReason"].ToString();
        //        LiveMoveInDate2.Text = reader2["LiveMoveInDate"].ToString();
        //        LiveMoveOutDate2.Text = reader2["LiveMoveOutDate"].ToString();
        //        CensusMoveInDate2.Text = reader2["CensusMoveInDate"].ToString();
        //        CensusMoveOutDate2.Text = reader2["CensusMoveOutDate"].ToString();


        //        EducationStatus.Text = reader2["EducationStatus"].ToString();
        //        LiveHomeStatus.Text = reader2["LiveHomeStatus"].ToString();
        //        DropDownList1.Text = reader2["Title"].ToString();



        //        //   RadioButtonList1.Text = reader2["FMstatust"].ToString();
        //        //     RadioButton1.Text = reader2["FMstatust"].ToString();
        //    }
        //    else
        //    {
        //        //MessageBox("ไม่พบเลขบัตรครับ");
        //    }
        //    conn.Close();
        //    reader2.Close();








        //}




        //protected void updatedatareg()
        //{


        //      string constr = WebConfigurationManager.ConnectionStrings["strconnection"].ConnectionString;
        //      SqlConnection conn2 = new SqlConnection(constr);

        //      SqlCommand CmdSql = new SqlCommand("UPDATE [Person] SET Gender=@Gender,BloodType=@BloodType,FirstName=@FirstName,LastName=@LastName,DOB=@DOB,Nation=@Nation,Race=@Race,Religion=@Religion,Foreigner=@Foreigner,LiveHomeStatus=@LiveHomeStatus,EducationStatus=@EducationStatus,LiveStreetAddress=@LiveStreetAddress,LiveStreetName=@LiveStreetName,Livetumbon=@Livetumbon,LiveCity=@LiveCity,LiveProvince=@LiveProvince,LivePostcode=@LivePostcode,CensusStreetAddress=@CensusStreetAddress,CensusStreetName=@CensusStreetName,Censustumbon=@Censustumbon,CensusCity=@CensusCity,CensusProvince=@CensusProvince,CensusPostcode=@CensusPostcode,HomePhone=@HomePhone,Mobile=@Mobile,DateTimeUpdate=@DateTimeUpdate,LiveMoveInDate=@LiveMoveInDate,LiveMoveOutDate=@LiveMoveOutDate,CensusMoveInDate=@CensusMoveInDate,CensusMoveOutDate=@CensusMoveOutDate,LiveMoveOutReason=@LiveMoveOutReason,CensusMoveOutReason=@CensusMoveOutReason WHERE CID=@CID", conn2);
        //    //

        //      //  ,[Gender]
        //      //    ,[BloodType]



        //    conn2.Open();


        //    CmdSql.Parameters.AddWithValue("@Gender", Gender.SelectedValue);
        //    CmdSql.Parameters.AddWithValue("@BloodType", BloodType.SelectedValue);
        //    CmdSql.Parameters.AddWithValue("@FirstName", FirstName.Text);
        //    CmdSql.Parameters.AddWithValue("@LastName", LastName.Text);
        //    CmdSql.Parameters.AddWithValue("@DOB", birthday.Text);
        //    CmdSql.Parameters.AddWithValue("@CID", CID.Text);
        //    CmdSql.Parameters.AddWithValue("@Nation", Nation.Text);
        //    CmdSql.Parameters.AddWithValue("@Race", Race.Text);
        //    CmdSql.Parameters.AddWithValue("@Religion", Religion.Text);
        //    CmdSql.Parameters.AddWithValue("@Foreigner", Foreigner.Text);
        //    CmdSql.Parameters.AddWithValue("@LiveHomeStatus", LiveHomeStatus.Text);
        //    CmdSql.Parameters.AddWithValue("@EducationStatus", EducationStatus.Text);

        //    //LiveStreetAddress=@LiveStreetAddress,LiveStreetName=@LiveStreetName,Livetumbon=@Livetumbon,LiveCity=@LiveCity,LiveProvince=@LiveProvince,LivePostcode=@LivePostcode,CensusStreetAddress=@CensusStreetAddress,CensusStreetName=@CensusStreetName,Censustumbon=@Censustumbon,CensusCity@CensusCity,CensusProvince=@CensusProvince,CensusPostcode=@CensusPostcode,HomePhone@HomePhone,Mobile=@Mobile,DateTimeUpdate=@DateTimeUpdate
        //    // LiveMoveInDate
            
        //    CmdSql.Parameters.AddWithValue("@LiveStreetAddress", LiveStreetAddress.Text);
        //    CmdSql.Parameters.AddWithValue("@LiveStreetName", LiveStreetName.Text);
        //    CmdSql.Parameters.AddWithValue("@Livetumbon", Livetumbon.Text);
        //    CmdSql.Parameters.AddWithValue("@LiveCity", LiveCity.Text);
        //    CmdSql.Parameters.AddWithValue("@LiveProvince", LiveProvince.Text);
        //    CmdSql.Parameters.AddWithValue("@LivePostcode", LivePostcode.Text);
        //    CmdSql.Parameters.AddWithValue("@CensusStreetAddress", CensusStreetAddress.Text);
        //    CmdSql.Parameters.AddWithValue("@CensusStreetName", CensusStreetName.Text);
        //    CmdSql.Parameters.AddWithValue("@Censustumbon", Censustumbon.Text);
        //    CmdSql.Parameters.AddWithValue("@CensusCity", CensusCity.Text);
        //    CmdSql.Parameters.AddWithValue("@CensusProvince", CensusProvince.Text);
        //    CmdSql.Parameters.AddWithValue("@CensusPostcode", CensusPostcode.Text);
        //    CmdSql.Parameters.AddWithValue("@HomePhone", HomePhone.Text);
        //    CmdSql.Parameters.AddWithValue("@Mobile", Mobile.Text);
        //    CmdSql.Parameters.AddWithValue("@RecordedStaffID", RecordedStaffID.Text);

        //    CmdSql.Parameters.AddWithValue("@DateTimeUpdate", DateTime.Now);
        //    CmdSql.Parameters.AddWithValue("@LiveMoveInDate", LiveMoveInDate2.Text);
        //    //CensusMoveInDate       CensusMoveOutDate LiveMoveOutReason  CensusMoveOutReason
        //    CmdSql.Parameters.AddWithValue("@LiveMoveOutReason", LiveMoveOutReason.SelectedValue);
        //    CmdSql.Parameters.AddWithValue("@CensusMoveOutReason", CensusMoveOutReason.SelectedValue);

        //    CmdSql.Parameters.AddWithValue("@LiveMoveOutDate", LiveMoveOutDate2.Text);
        //    CmdSql.Parameters.AddWithValue("@CensusMoveOutDate", CensusMoveOutDate2.Text);
        //    CmdSql.Parameters.AddWithValue("@CensusMoveInDate", CensusMoveInDate2.Text);
        //    CmdSql.ExecuteNonQuery();
        //    conn2.Close();


      



        //    MessageBox("ลงทะเบียนเรียบร้อยครับ");

        //    Response.Redirect("~/regok.aspx");








          
        //}




        protected void edit_button_Click(object sender, EventArgs e)
        {
            
        }

        protected void notcid_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/reg2.aspx");
        }




        }





    }







